package com.star.mapper;

import com.github.pagehelper.Page;
import com.star.annotation.AutoFill;
import com.star.dto.BusinessPageQueryDTO;
import com.star.entity.Admin;
import com.star.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AdminMapper {

    @Select("select * from admin where username = #{username}")
    Admin getByUsername(String username);

    @Select("select * from admin where id = #{id}")
    Admin getById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Admin admin);

    Page<Admin> pageQuery(BusinessPageQueryDTO businessPageQueryDTO);

    @Insert("insert into admin (name, username, password, status, create_time, update_time, create_user, update_user)" +
            "values" +
            "(#{name}, #{username}, #{password}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Admin admin);
}
